package com.xiyu.service.controller.admin.elder;
import com.xiyu.service.vo.elder.elderInfo.ElderInfoGetOutput;
import com.xiyu.service.vo.elder.elderInfo.ElderInfoUpdateInput;
import com.xiyu.service.vo.elder.elderInfo.ElderInfoInsertInput;
import com.xiyu.service.vo.elder.elderInfo.ElderInfoQueryOutput;
import com.xiyu.service.vo.elder.elderInfo.ElderInfoQueryInput;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.constraints.*;
import jakarta.validation.*;
import jakarta.servlet.http.*;

import com.xiyu.service.framework.web.web.core.pojo.PageResult;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.framework.excel.core.util.ExcelUtils;

import com.xiyu.service.framework.operateLog.core.annotations.OperateLog;
import static com.xiyu.service.framework.operateLog.core.enums.OperateTypeEnum.*;

import com.xiyu.service.service.elder.ElderInfoService;

@Tag(name = "老人资料")
@RestController
@RequestMapping("/elder/elder-info")
@Validated
public class ElderInfoController {

    @Resource
    private ElderInfoService elderInfoService;

    @GetMapping("/query")
    @Operation(summary = "老人资料-查询")
    @PreAuthorize("@ss.hasPermission('elder:info:query')")
    public CommonResult<PageResult<ElderInfoQueryOutput>> query(@Valid ElderInfoQueryInput inputVO) {
        return success(elderInfoService.query(inputVO));
    }

    @PostMapping("/insert")
    @Operation(summary = "老人资料-新建")
    @PreAuthorize("@ss.hasPermission('elder:info:insert')")
    public CommonResult<Long> insert(@Valid @RequestBody ElderInfoInsertInput inputVO) {
        return success(elderInfoService.insert(inputVO));
    }

    @PostMapping("/update")
    @Operation(summary = "老人资料-更新")
    @PreAuthorize("@ss.hasPermission('elder:info:update')")
    public CommonResult<Long> update(@Valid @RequestBody ElderInfoUpdateInput inputVO) {
        return success(elderInfoService.update(inputVO));
    }

    @GetMapping("/get")
    @Operation(summary = "获取老人信息")
    @Parameter(name = "id", description = "老人ID", required = true, example = "1")
    public CommonResult<ElderInfoGetOutput> get(@RequestParam("id") Long id) {
        return success(elderInfoService.get(id));
    }

}
